package com.simpou.commons.utils.tests;

import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;

import org.junit.runner.notification.RunNotifier;

import org.junit.runners.model.FrameworkMethod;


/**
 * Item de execução de um teste. Use para enfileirar a execução de testes.
 *
 * @author Jonas Pereira
 * @since 2011-10-04
 * @version 2012-05-15
 */
@Getter(AccessLevel.PACKAGE)
@EqualsAndHashCode(exclude =  {
    "testOrder"}
)
class TestExecutionQueueItem implements Comparable<TestExecutionQueueItem> {
    /**
     * Método a ser executado.
     */
    private final FrameworkMethod method;

    /**
     * Notificador do JUnit.
     */
    private final RunNotifier notifier;

    /**
     * Ordem de execução do método.
     */
    private Integer testOrder;

    /**
     * <p>Constructor for TestExecutionQueueItem.</p>
     *
     * @param method a {@link org.junit.runners.model.FrameworkMethod} object.
     * @param notifier a {@link org.junit.runner.notification.RunNotifier}
     * object.
     * @param testOrder a int.
     */
    TestExecutionQueueItem(final FrameworkMethod method,
        final RunNotifier notifier, final int testOrder) {
        this.method = method;
        this.notifier = notifier;
        this.testOrder = testOrder;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int compareTo(final TestExecutionQueueItem item) {
        return testOrder - item.testOrder;
    }
}
